const infomation = document.getElementById('info')
infomation.innerText = `本应用正在使用Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), 和Electron (v${versions.electron})`

const setButton = document.getElementById('btn')
const titleInput = document.getElementById('title')
setButton.addEventListener('click', () => {
    const title = titleInput.value
    window.electronAPI.setTitle(title)
})

const openFileBut = document.getElementById('openFileBut')
const filePathElement = document.getElementById('filePath')
openFileBut.addEventListener('click', async () => {
    const filePath = await window.electronAPI.openFile()
    filePathElement.innerText = filePath
})

const counter = document.getElementById('counter')
window.electronAPI.onUpdateCounter((event, value) => {
    const oldValue = Number(counter.innerText)
    const newValue = oldValue + value
    counter.innerText = newValue
    event.sender.send('counter-value', newValue)
})

const btnNewWin = document.getElementById('btnNewWin')
btnNewWin.addEventListener('click',(event)=>{
    console.log("点击")
    window.electronAPI.openNewWin()
})
